package pure.ui 
{
	import flash.filters.DropShadowFilter;
	import flash.filters.GlowFilter;
	import flash.geom.Point;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	
	/**
	 * 文本标签
	 * @author des
	 * 
	 */
	
public class Label extends TextField 
{
	public function Label(html:String, x:Number, y:Number, size:Point = null, isAutoSize:Boolean = true) 
	{
		_init();
		this.htmlText = html;
		move(x, y);	
		this.isAutoSize = isAutoSize;
		if (size) 
		{
			setSize(size.x, size.y);
		}
	}
	
	
	private var _isAutoSize:Boolean;	// 是否自动适应大小

	
	
	/**
	 * 位置
	 **/
	public function move(x:Number, y:Number):void
	{
		this.x = x;
		this.y = y;
	}
	
	/**
	 * 大小
	 **/
	public function setSize(w:Number, h:Number):void
	{
		this.width = w;
		this.height = h;
	}

	/**
	 * 添加边框
	 * @param b			是否拥有边框
	 * @param color		颜色
	 * @param blur		模糊
	 * @param strength	强度
	 **/
	public function addBorder(b:Boolean, color:uint = 0, blur:int = 4, strength:int = 22 ):void
	{
		if (b)
		{
			this.filters = [new GlowFilter(color, 0.9, blur, blur , strength) ];
		}
		else 
		{
			this.filters = null;
		}
	}
	
	
	
	
	
	/* ----------------------------------------------------    get / set    ----------------------------------------------------*/
	
	
	
	
	
	// 是否自动适应大小
	public function set isAutoSize(b:Boolean):void
	{
		if (this._isAutoSize != b) {
			this._isAutoSize = b;
			if (this._isAutoSize)
			{
				this.autoSize = TextFieldAutoSize.LEFT;
			}
			else 
			{
				this.autoSize = TextFieldAutoSize.NONE;
			}
		}
	}
	
	public function get isAutoSize():Boolean
	{
		return _isAutoSize;
	}
	
	

	
	
	/* ----------------------------------------------------    private    ----------------------------------------------------*/
	
	
	
	
	
	private function _init():void
	{
		this.selectable = false;
		this.mouseEnabled = false;
		this.multiline = true;
		this.wordWrap = true;
		this._isAutoSize = false;
	}
}

}